/**
 * 自动注销
 */
export interface Dispose {
    dispose(): boolean;
    isDisposed(): boolean;
}
/**
 * 可执行的
 */
export interface Runable {
    run(): void;
}
/**
 * 动作
 */
export class Action<T = any> {
    type: string;
    title: string;
    payload?: T;
    visit(visitor: ActionVisitor, ctx: T): T {
        return visitor.visitAction(this, ctx)
    }
}

export class ActionVisitor {
    visitAction<T = any>(action: Action<T>, ctx: T): any {
        return this[action.type](action, ctx)
    }
}
/**
 * 状态
 */
export interface State<T> {
    currentState: T;
    initState: T;
}

export interface ThreadGroup {

}
export interface UncaughtExceptionHandler {

}
export interface Thread {
    start(): void;
    setName(name?: string): void;
    setDaemon(isDaemon?: boolean): void;
    isInterrupted(): boolean;
    isDaemon(): boolean;
    isAlive(): boolean;
    interrupted(): boolean;
    interrupt(): void;
    setPriority(newPriority: number): void;
    sleep(m: number): void;
    join(m?: number): void;
    yield(): void;
    toString(): string;
    getThreadGroup(): ThreadGroup;
    getContextClassLoader(): any;
    holdsLock(obj: any): boolean;
    getState(): any;
    getStackTrace(): any;
    getId(): number;
    getName(): string;
    getPriority(): number;
}
export function createThread(run: Runable, isDaemon: boolean = true): Thread {
    const r = new java.lang.Runnable(run)
    const t = new java.lang.Thread(r);
    t.setDaemon(isDaemon);
    return t;
}

export function createRunable(run: Runable): Runable {
    return new java.lang.Runnable(run)
}
